﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Model;
using University.Workshop.Business;
using System.Data.SqlClient;

namespace University.Workshop.Presenters
{
    public class PresenterMedicine
    {
        /// <summary>
        /// Declaring Interface
        /// </summary>
        IMedicine im;
        
        /// <summary>
        /// builder
        /// </summary>
        /// <param name="im">Interface that interacts with presenter</param>
        public PresenterMedicine(IMedicine im)
        {
            this.im = im;
        }

        
        /// <summary>
        /// Register the new medicine
        /// </summary>
        public string PresenterMedicineRegister()
        {
            Medicine m = new Medicine(im.Id, im.Brand, im.Generic, im.Price, im.Quantity, im.Expiration, im.Lot);
            try
            {
                MedicineManager.NewMedicine(m);
                return SystemMessages.MedicineCorrectRegister;
            }
            catch (SqlException)
            {
                return SystemMessages.MedicineRegisterError;
            }
        }

        static public ICollection<Medicine> MedicineLow()
        {
            return MedicineManager.MedicinesLow();
        }

        static public ICollection<Medicine> ExpiredMedicine()
        {
            return MedicineManager.ExpiredMedicines();          
        }
    }
}
